const { DataTypes } = require('sequelize');
const sequelize = require('../config/db');

const Category = sequelize.define('product_category', {
    id: {
        type: DataTypes.BIGINT,
        primaryKey: true,
        autoIncrement: true,
        comment: '分类 ID'
    },
    name: {
        type: DataTypes.STRING(50),
        allowNull: false,
        comment: '分类名称'
    },
    parent_id: {
        type: DataTypes.BIGINT,
        defaultValue: 0,
        comment: '父分类 ID'
    },
    sort: {
        type: DataTypes.INTEGER,
        defaultValue: 0,
        comment: '排序'
    },
    status: {
        type: DataTypes.TINYINT,
        defaultValue: 1,
        comment: '状态:0 禁用,1 启用'
    }
}, {
    tableName: 'product_category',
    timestamps: true,
    createdAt: 'created_at',
    updatedAt: 'updated_at'
});

module.exports = Category;